package com.xtq.aop.proxy;


import com.xtq.annotations.After;
import com.xtq.annotations.Before;
import com.xtq.annotations.Pointcut;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.List;

public class AOPProxy {
    // 创建代理对象
    public static <T> T createProxy(Class<T> targetInterface, Object targetClassInstance, List<Object> aspects) {
        return (T) Proxy.newProxyInstance(
                targetInterface.getClassLoader(),
                new Class<?>[]{targetInterface},
                new AOPInvocationHandler(targetClassInstance, aspects)
        );
    }
}
